	{{#allParams}}
	{{#minItems}}
    if {{^required}}r.{{paramName}} != nil && {{/required}}len({{> api_request_param}}) < {{minItems}} {
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
	}
	{{/minItems}}
	{{#maxItems}}
	if {{^required}}r.{{paramName}} != nil && {{/required}}len({{> api_request_param}}) > {{maxItems}} {
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements")
	}
	{{/maxItems}}
	{{#minLength}}
	if {{^required}}r.{{paramName}} != nil && {{/required}}strlen({{> api_request_param}}) < {{minLength}} {
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have at least {{minLength}} elements")
	}
	{{/minLength}}
	{{#maxLength}}
	if {{^required}}r.{{paramName}} != nil && {{/required}}strlen({{> api_request_param}}) > {{maxLength}} {
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements")
	}
	{{/maxLength}}
	{{#minimum}}
	{{#isString}}
	{{paramName}}Txt, err := atoi({{> api_request_param}})
	if {{paramName}}Txt < {{minimum}} {
	{{/isString}}
	{{^isString}}
	if {{^required}}r.{{paramName}} != nil && {{/required}}{{> api_request_param}} < {{minimum}} {
	{{/isString}}
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be greater than {{minimum}}")
	}
	{{/minimum}}
	{{#maximum}}
	{{#isString}}
	{{paramName}}Txt, err := atoi({{> api_request_param}})
	if {{paramName}}Txt > {{maximum}} {
	{{/isString}}
	{{^isString}}
	if {{^required}}r.{{paramName}} != nil && {{/required}}{{> api_request_param}} > {{maximum}} {
	{{/isString}}
		return {{#returnType}}localVarReturnValue, {{/returnType}}nil, reportError("{{paramName}} must be less than {{maximum}}")
	}
	{{/maximum}}
	{{/allParams}}

	{{#queryParams}}
	{{#required}}
	{{#isCollectionFormatMulti}}
	{
		t := {{> api_request_param}}
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				localVarQueryParams.Add("{{baseName}}", parameterToString(s.Index(i), "{{collectionFormat}}"))
			}
		} else {
			localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{collectionFormat}}"))
		}
	}
	{{/isCollectionFormatMulti}}
	{{^isCollectionFormatMulti}}
	localVarQueryParams.Add("{{baseName}}", parameterToString({{> api_request_param}}, "{{collectionFormat}}"))
	{{/isCollectionFormatMulti}}
	{{/required}}
	{{^required}}
	if r.{{paramName}} != nil {
	{{#isCollectionFormatMulti}}
		t := {{> api_request_param}}
		if reflect.TypeOf(t).Kind() == reflect.Slice {
			s := reflect.ValueOf(t)
			for i := 0; i < s.Len(); i++ {
				localVarQueryParams.Add("{{baseName}}", parameterToString(s.Index(i), "{{collectionFormat}}"))
			}
		} else {
			localVarQueryParams.Add("{{baseName}}", parameterToString(t, "{{collectionFormat}}"))
		}
	{{/isCollectionFormatMulti}}
	{{^isCollectionFormatMulti}}
		localVarQueryParams.Add("{{baseName}}", parameterToString({{> api_request_param}}, "{{collectionFormat}}"))
	{{/isCollectionFormatMulti}}
	}
	{{/required}}
	{{/queryParams}}
	// to determine the Content-Type header
{{=<% %>=}}
	localVarHTTPContentTypes := []string{<%#consumes%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/consumes%>}
<%={{ }}=%>

	// set Content-Type header
	localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
	if localVarHTTPContentType != "" {
		localVarHeaderParams["Content-Type"] = localVarHTTPContentType
	}

	// to determine the Accept header
{{=<% %>=}}
	localVarHTTPHeaderAccepts := []string{<%#produces%>"<%&mediaType%>"<%^-last%>, <%/-last%><%/produces%>}
<%={{ }}=%>

	// set Accept header
	localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
	if localVarHTTPHeaderAccept != "" {
		localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
	}
{{#headerParams}}
	{{#required}}
	localVarHeaderParams["{{baseName}}"] = parameterToString({{> api_request_param}}, "{{collectionFormat}}")
	{{/required}}
	{{^required}}
	if r.{{paramName}} != nil {
		localVarHeaderParams["{{baseName}}"] = parameterToString({{> api_request_param}}, "{{collectionFormat}}")
	}
	{{/required}}
{{/headerParams}}
{{#formParams}}
{{#isFile}}
	var {{paramName}}LocalVarFormFileName string
	var {{paramName}}LocalVarFileName     string
	var {{paramName}}LocalVarFileBytes    []byte

	{{paramName}}LocalVarFormFileName = "{{baseName}}"

{{#required}}
	{{paramName}}LocalVarFile := {{> api_request_param}}
{{/required}}
{{^required}}
	var {{paramName}}LocalVarFile {{dataType}}
	if r.{{paramName}} != nil {
		{{paramName}}LocalVarFile = {{> api_request_param}}
	}
{{/required}}
	if {{paramName}}LocalVarFile != nil {
		fbs, _ := ioutil.ReadAll({{paramName}}LocalVarFile)
		{{paramName}}LocalVarFileBytes = fbs
		{{paramName}}LocalVarFileName = {{paramName}}LocalVarFile.Name()
		{{paramName}}LocalVarFile.Close()
	}
	formFiles = append(formFiles, formFile{fileBytes: {{paramName}}LocalVarFileBytes, fileName: {{paramName}}LocalVarFileName, formFileName: {{paramName}}LocalVarFormFileName})
{{/isFile}}
{{^isFile}}
{{#required}}
	localVarFormParams.Add("{{baseName}}", parameterToString({{> api_request_param}}, "{{collectionFormat}}"))
{{/required}}
{{^required}}
{{#isModel}}
	if r.{{paramName}} != nil {
		paramJson, err := parameterToJson({{> api_request_param}})
		if err != nil {
			return {{#returnType}}localVarReturnValue, {{/returnType}}nil, err
		}
		localVarFormParams.Add("{{baseName}}", paramJson)
	}
{{/isModel}}
{{^isModel}}
	if r.{{paramName}} != nil {
		localVarFormParams.Add("{{baseName}}", parameterToString({{> api_request_param}}, "{{collectionFormat}}"))
	}
{{/isModel}}
{{/required}}
{{/isFile}}
{{/formParams}}
{{#bodyParams}}
	// body params
    {{^required}}
    if r.{{paramName}} != nil {
    {{/required}}
    {{#required}}
    if !checkNilInterface(r.{{paramName}}) {
    {{/required}}
        localVarPostBody = r.{{paramName}}
    }
{{/bodyParams}}